﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.Views.Common
{
    public partial class NewTicketSubmit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Form["from"] != null && Request.Form["email"] != null)
                {
                    string Linkman = Request.Form["name"];
                    string Telphone = Request.Form["mobile"];
                    string Email = Request.Form["email"];
                    string FromCity = Request.Form["newfrom"];
                    string ToCity = Request.Form["to"];
                    string TicketNumber = Request.Form["number"];
                    string TicketType = Request.Form["type"];
                    string TicketDate = Request.Form["date"];
                    string Amount = Request.Form["count"];
                    bool IsCHD = string.IsNullOrEmpty(Request.Form["IsCHD"]) ? false : true;

                    Easydp.Models.Entities.TT_TransferTicket obj = new Easydp.Models.Entities.TT_TransferTicket();
                    obj.Linkman = Linkman;
                    obj.Telphone = Telphone;
                    obj.Email = Email;
                    obj.FromCity = FromCity;
                    obj.ToCity = ToCity;
                    obj.TicketNumber = TicketNumber;
                    obj.TicketType = TicketType;
                    obj.TicketDate = string.IsNullOrEmpty(TicketDate) ? DateTime.Now : DateTime.Parse(TicketDate);
                    obj.Amount = Amount;
                    obj.IsCHD = IsCHD;
                    int key = 0;
                    string ResMsg = (new Easydp.Controllers.TransferTicketController()).Insert(obj, out key);

                    if (key <= 0)
                    {
                        DivSuccessed.Style.Value = "display:none";
                        DivFailing.Style.Value = "display:black";
                    }
                    else
                    {
                        aTicketInfo.HRef = string.Format(aTicketInfo.HRef, key);
                    }

                }
                else
                {
                    Response.Redirect("/Default.aspx");
                }
            }
        }
    }
}
